using System;
using System.Collections.Generic;
using System.Text;
using LispLib;

namespace GeneticAlgorithm.CP3
{
    class Problem : Problem<Interpreter.Pair, float[]>
    {
        public override float[] Evaluate(Interpreter.Pair solution)
        {
            List<float> result = new List<float>();

            // HACK get lisp expression result at 10 different input
            for (int i = 0; i < 50; i++)
            {
                Interpreter interpreter = new Interpreter();
                string setTime = "(set (time " + i + "))";
                interpreter.Eval(setTime);
                Object o = Interpreter.EvalTerm(solution, interpreter.Globals);
                Decimal d = (Decimal)o;
                result.Add((float)(Decimal.ToDouble(d)));
            }

            return result.ToArray();
        }
    }
}
